import requests
from lxml import etree

# 需求:4K图片解析爬取

if __name__ == '__main__':
    url = 'https://pic.netbian.com/4kmeinv/'
    # UA伪装: 将对应的User-Agent封装到一个字典中
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
    }

    page_text = requests.get(url=url,headers=headers).text
    tree = etree.HTML(page_text)
    img_lst = tree.xpath('//ul[@class="clearfix"]/li/a/img/@src')

    for img_url in img_lst:
        img_url = 'https://pic.netbian.com'+img_url
        print(img_url)